package ui
{
	import util.err.SingletonInstantiationErr;
	
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	
	import mx.controls.Alert;

	public class AlertManager
	{
		private static var _instance:AlertManager;
		
		private var _parent:Sprite;
		
		public function AlertManager()
		{
			if( _instance ) throw new SingletonInstantiationErr();
		}
		
		public function init( parent:Sprite ):void
		{
			_parent = parent;
		}
		
		public function alarm( text:String, parent:Sprite=null, closeHandler:Function=null ):void
		{
			show( text, "警告" );
		}
		
		
		public function show( text:String, title:String, closeHandler:Function = null, iconClass:Class = null, parent:Sprite = null  ):void
		{
			if( !parent )
			{
				parent = _parent;
			}
			
			Alert.show( text, title, Alert.OK, parent, closeHandler, iconClass  );
			
		}
			
		
		public static function instance():AlertManager
		{
			if( !_instance )
			{
				_instance = new AlertManager();
			}
			
			return _instance;
		}
	}
}